
import './aoth.css'
import { useNavigate } from 'react-router-dom'
import { delay } from '../../utils/utils'
import { useSelector, useDispatch } from 'react-redux';
import { loginAction } from '../../store/action/num'

function Aoth () {
  
  const dispatch = useDispatch();
  const navigate = useNavigate();
  const count = useSelector(state => state.chat.login);

  if (count) {
    delay("/personalchat/index", 0, navigate);
  }

  let data;
  const toProject = (path) => {
    if (data && data == "twlchat") {
      localStorage.setItem("WsUid", data);
      dispatch({
        type: loginAction().type,
        state: { login: true },
      })
      delay(path, 0.2, navigate);
    }
  }

  const handleChange = (event) => {
    data = event.target.value;
  }

  return (
    <div>

      <div className='global index-local'>
        <div className='aoth-div'>
          <input className='aoth-input' placeholder='你应该知道你要输入什么' onChange={handleChange} />
        </div>
        <div className='aoth-but' onClick={toProject.bind(this, "/personalchat/index")}>进入</div>
      </div>

    </div >
  );
}

export default Aoth;